#include <core/io.h>
#include <core/init.h>
#include <arch/arm.h>
#include <autoconf.h>
//#include <arch/at91sam926x.h>

#define CONF_PIO_PC10 (1 << 10)

static __INIT__ int MW9263Init(void)
{
	UINT32 dwMask;

	PLAT_INFO("MW9263 Board.\n");


	At91PioConfInput(PIOE, 1 << 31, 0);
//	WriteLong(1 << 31, AT91SAM926X_PA_PIOE + PIO_IFER);


	At91PioConfPeriB(PIOC, 1 << 25, 0);	// ERXDV

	dwMask = 1 << 21 | // ETXCK_EREFCK
		1 << 23 |  // ETX0
		1 << 24 |  // ETX1
		1 << 25 |  // ERX0
		1 << 26 |  // ERX1
		1 << 27 |  // ERXER
		1 << 28 |  // ETXEN
		1 << 29 |  // EMDC
		1 << 30;   // EMDIO
	At91PioConfPeriA(PIOE, dwMask, 0);


	At91RstcWrite(RSTC_MR, (0xA5 << 24) | (0x0d << 8) | 0x1);
	At91RstcWrite(RSTC_CR, (0xA5 << 24) | (0x1 << 3));

	while (!(At91RstcRead(RSTC_SR) & (0x1 << 16)));


	At91sam926xInitIrq();

	return 0;
}

PLAT_INIT(MW9263Init);

